

const path = require('path');
const staticImg = path.join(__dirname, 'static');

function SensorbitUnoBlocks(Blockly) {
    var base_color = "#179b73";



    //钢琴模块初始化端口
    Blockly.Blocks.microbit_pianoInit = {
        init:function(){
        this.setColour(base_color);
        this.appendDummyInput("")
         .appendField(new Blockly.FieldImage(staticImg+"/33.Touch  Piano.svg", 84, 42))
           .appendField(Blockly.Msg.MICROBIT_PIANO)
           .appendField(new Blockly.FieldDropdown([
            ['P1', "pin1"],
            ['P8', "pin8"],
            ['P12', "pin12"],
            ['P13', "pin13"],
            ['P15', "pin15"],
           ]),"pianoCLK")
           .appendField(Blockly.Msg.MICROBIT_DIO)
           .appendField(new Blockly.FieldDropdown([
            ['P1', "pin1"],
            ['P2', "pin2"],
            ['P12', "pin12"],
            ['P14', "pin14"],
            ['P16', "pin16"],
           ]),"pianoDIO")
           this.setPreviousStatement(true, null);
           this.setNextStatement(true, null);
           this.setTooltip('');
        }
    };

    //钢琴模块 获取钢琴值
    Blockly.Blocks.microbit_getPianoKey = {
        init:function(){
        this.setColour(base_color);
        this.appendDummyInput("")
        .appendField(new Blockly.FieldImage(staticImg+"/33.Touch  Piano.svg", 84, 42))
        .appendField(Blockly.Msg.MICROBIT_GETPIANOKEY)
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setTooltip('');
        }
    };

    //钢琴模块
    Blockly.Blocks.microbit_piano = {
        init:function(){
        this.setColour(base_color);
        this.appendDummyInput("")
        .appendField(new Blockly.FieldImage(staticImg+"/33.Touch  Piano.svg", 84, 42))
        .appendField(Blockly.Msg.MICROBIT_PIANOPRESS)
        .appendField(new Blockly.FieldDropdown([
            ['1', "1"],
            ['2', "2"],
            ['3', "3"],
            ['4', "4"],
            ['5', "5"],
            ['6', "6"],
            ['7', "7"],
            ['8', "8"],
        ]),"piano2")
        this.appendDummyInput("")
        .appendField(Blockly.Msg.MICROBIT_QUESTIONMARK)
        this.setOutputShape(Blockly.OUTPUT_SHAPE_HEXAGONAL);
            this.setOutput(true, 'Boolean');
            this.setTooltip('');
        }
    };

    return Blockly;
}

module.exports = SensorbitUnoBlocks;

